function [] = csv2bbr(fin)
[directory name ext] = fileparts(fin);
fout = [directory '\' name '_bbr' ext];

data = dlmread(fin);
nRows = size(data,1);
if(length(intersect(data(:,1),[1:nRows])) == length(data(:,1)))
    y = data(:,2);
    x = data(:,3:end);
else
    y = data(:,1);
    x = data(:,2:end);
end

nCols = size(x,2);
indicator = 0;
dense = 1;
formatType = zeros(1,nCols);
for i = 1:nCols,
    if(length(setdiff(unique(x(:,i)),[0,1])) > 1)
        formatType(i) = dense;
    else
        formatType(i) = indicator;
    end
end

fp = fopen(fout,'w');
for i = 1:nRows,
    fprintf(fp,'%d',y(i));
    for j = 1:nCols,
        if(formatType(j) == dense)
            fprintf(fp,' %d:%f',j,x(i,j));
        else
            if(x(i,j) == Inf)
                fprintf(fp,' %d:Inf',j);
            elseif(x(i,j) ~= 0)
                fprintf(fp,' %d:1',j);
            end
        end
    end
    fprintf(fp,'\n');
end
fclose(fp);

return